package com.nanhai.buddhist.college.module.collegebase.dal.mysql.teacherremuneration;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.nanhai.buddhist.college.module.collegebase.controller.admin.teacherremuneration.vo.TeacherRemunerationExportReqVO;
import com.nanhai.buddhist.college.module.collegebase.controller.admin.teacherremuneration.vo.TeacherRemunerationPageReqVO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.colleges.CollegesDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.departments.DepartmentsDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.teacherremuneration.TeacherRemunerationDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.teacherteachers.TeacherTeachersDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 教师薪酬 Mapper
 *
 * @author AKai
 */
@Mapper
public interface TeacherRemunerationMapper extends BaseMapperX<TeacherRemunerationDO> {

    default PageResult<TeacherRemunerationDO> selectPage(TeacherRemunerationPageReqVO reqVO) {
        return selectPageForJoin(reqVO,TeacherRemunerationDO.class, new MPJLambdaWrapperX<TeacherRemunerationDO>()
                .eqIfPresent(TeacherRemunerationDO::getCollegeId, reqVO.getCollegeId())
                .eqIfPresent(TeacherRemunerationDO::getDepartmentsId, reqVO.getDepartmentsId())
                .likeIfPresent(TeacherTeachersDO::getTeacherName,reqVO.getTeacherName())
                .leftJoin(DepartmentsDO.class,DepartmentsDO::getId,TeacherRemunerationDO::getDepartmentsId)
                .leftJoin(CollegesDO.class,CollegesDO::getId,TeacherRemunerationDO::getCollegeId)
                .leftJoin(TeacherTeachersDO.class,TeacherTeachersDO::getId,TeacherRemunerationDO::getTeacherId)
                .selectAll(TeacherRemunerationDO.class)
                .selectAs(TeacherTeachersDO::getTeacherName,TeacherRemunerationDO::getTeacherName)
                .selectAs(DepartmentsDO::getDepartmentName,TeacherRemunerationDO::getDepartmentName)
                .selectAs(CollegesDO::getCollegeName,TeacherRemunerationDO::getCollegeName)
                .orderByDesc(TeacherRemunerationDO::getId));
    }

    default List<TeacherRemunerationDO> selectList(TeacherRemunerationExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TeacherRemunerationDO>()
                .eqIfPresent(TeacherRemunerationDO::getCollegeId, reqVO.getCollegeId())
                .eqIfPresent(TeacherRemunerationDO::getDepartmentsId, reqVO.getDepartmentsId())
                .eqIfPresent(TeacherRemunerationDO::getTeacherId, reqVO.getTeacherId())
                .orderByDesc(TeacherRemunerationDO::getId));
    }

}
